using Perfect.Marshal;
using System.Xml;

namespace editor
{
namespace cfg.role
{
[System.Serializable]
public  class RoleConfig :   cfg.EditorReadWriter 
 {

    public int initMapId ;
     public cfg.map.Vector3 initPosition  = new cfg.map.Vector3();
     public cfg.map.Vector3 initDirecton  = new cfg.map.Vector3();
     public float jumpSpeed ;
     public int normalAttack ;
     public cfg.obj.CharacterController defaultCharacterController  = new cfg.obj.CharacterController();
     


    public const int TYPE_ID = 409859482;

    public override int GetTypeId() {
        return TYPE_ID;
    }


    public override void MarshalCompatible(Perfect.Marshal.Octets os) {
        os.WriteSize(6);
        os.WriteSize(Tag.INT | (1 << Tag.TAG_SHIFT));  os.WriteInt(initMapId);  
         os.WriteSize(Tag.BEAN | (2 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_map_Vector3(initPosition,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.BEAN | (3 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_map_Vector3(initDirecton,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.FLOAT | (4 << Tag.TAG_SHIFT));  os.WriteFloat(jumpSpeed);  
         os.WriteSize(Tag.INT | (5 << Tag.TAG_SHIFT));  os.WriteInt(normalAttack);  
         os.WriteSize(Tag.BEAN | (6 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_obj_CharacterController(defaultCharacterController,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         
    }

    public override void UnmarshalCompatible(Perfect.Marshal.Octets os) {
        for (int _var_num_ = os.ReadSize(); _var_num_-- > 0; ) {
            int _id_ = os.ReadSize();
            switch (_id_)
            {
            case (Tag.INT | (1 << Tag.TAG_SHIFT)):   initMapId = os.ReadInt(); break;  
             case (Tag.BEAN | (2 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); initPosition = cfg.Extensions.unmarshal_compatible_cfg_map_Vector3(os); os = _oldOs; break; }   
             case (Tag.BEAN | (3 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); initDirecton = cfg.Extensions.unmarshal_compatible_cfg_map_Vector3(os); os = _oldOs; break; }   
             case (Tag.FLOAT | (4 << Tag.TAG_SHIFT)):   jumpSpeed = os.ReadFloat(); break;  
             case (Tag.INT | (5 << Tag.TAG_SHIFT)):   normalAttack = os.ReadInt(); break;  
             case (Tag.BEAN | (6 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); defaultCharacterController = cfg.Extensions.unmarshal_compatible_cfg_obj_CharacterController(os); os = _oldOs; break; }   
             
            default: Tag.SkipUnknownField(_id_, os); break;
            }
         }
    }
    public override void MarshalXml(XmlWriter ele)
    {
        ele.WriteAttributeString("type", "RoleConfig");
        ele.WriteStartElement("initMapId"); ele.WriteAttributeString("id", "1"); ele.WriteInt(initMapId); ele.WriteEndElement();
         ele.WriteStartElement("initPosition"); ele.WriteAttributeString("id", "2"); cfg.Extensions.xml_marshal_cfg_map_Vector3(initPosition,ele); ele.WriteEndElement();
         ele.WriteStartElement("initDirecton"); ele.WriteAttributeString("id", "3"); cfg.Extensions.xml_marshal_cfg_map_Vector3(initDirecton,ele); ele.WriteEndElement();
         ele.WriteStartElement("jumpSpeed"); ele.WriteAttributeString("id", "4"); ele.WriteFloat(jumpSpeed); ele.WriteEndElement();
         ele.WriteStartElement("normalAttack"); ele.WriteAttributeString("id", "5"); ele.WriteInt(normalAttack); ele.WriteEndElement();
         ele.WriteStartElement("defaultCharacterController"); ele.WriteAttributeString("id", "6"); cfg.Extensions.xml_marshal_cfg_obj_CharacterController(defaultCharacterController,ele); ele.WriteEndElement();
         
    }

    public override void UnmarshalXml(XmlElement ele)
    {
        foreach (XmlElement e in ele.GetChildren())
        {
            if (int.TryParse(ele.GetAttribute("id"), out var _id_))
            {
                switch (_id_)
                {
                case 1:  initMapId = ele.ReadInt(); break; 
                 case 2:  initPosition = cfg.Extensions.xml_unmarshal_cfg_map_Vector3(ele); break; 
                 case 3:  initDirecton = cfg.Extensions.xml_unmarshal_cfg_map_Vector3(ele); break; 
                 case 4:  jumpSpeed = ele.ReadFloat(); break; 
                 case 5:  normalAttack = ele.ReadInt(); break; 
                 case 6:  defaultCharacterController = cfg.Extensions.xml_unmarshal_cfg_obj_CharacterController(ele); break; 
                 
                default: break;
                }
            }
            else
            {
                switch (e.Name)
                {
                case "init_map_id":  initMapId = ele.ReadInt(); break; 
                 case "init_position":  initPosition = cfg.Extensions.xml_unmarshal_cfg_map_Vector3(ele); break; 
                 case "init_directon":  initDirecton = cfg.Extensions.xml_unmarshal_cfg_map_Vector3(ele); break; 
                 case "jump_speed":  jumpSpeed = ele.ReadFloat(); break; 
                 case "normal_attack":  normalAttack = ele.ReadInt(); break; 
                 case "default_character_controller":  defaultCharacterController = cfg.Extensions.xml_unmarshal_cfg_obj_CharacterController(ele); break; 
                 
                default: break;
                }
            }
        }
    }
}
}
}
